Skip to content

feat(db): wallet RLS migration and vyloop_app role (RLS unit 6) - #347

Merged
juancodedev merged 1 commit into
mainfrom
feat/rls-unit6-wallet
Nov 5, 2026
Merged

juancodedev merged 1 commit into
mainfrom
feat/rls-unit6-wallet

Conversation

@juancodedev

Copy link
Copy Markdown
Owner

Summary

Unit 6 of tenant-isolation-rls: turns RLS on for the wallet phase. Do not merge before 0026 is applied to production. The migration-drift gate blocks every deploy until it is.

  • 0026_wallet_rls.sql enables RLS and creates the tenant_isolation policy on the three TENANT_ID_TABLES.
    • It also records push_campaigns. Production already had RLS and this exact policy on that table, applied outside any migration.
    • A new test asserts the file's statements are exactly the ones rls.ts generates.
    • The production apply drops the existing push_campaigns policy in the same transaction, so the table is never without it.
  • check-rls: the wallet phase now includes push_campaigns (RLS_BATCHES.wallet).
  • docs/09 §4:
    • the credential decision: one vyloop_app secret for the workers, the gateway and the drift job; the owner credential stays out of CI and runtime;
    • the vyloop_app runbook;
    • the production order with a rollback for each step.
  • The drift baseline is regenerated: it has 0026 with its rls and policy evidence.

Rehearsal (Neon branch copied from production)

Everything below ran connected as vyloop_app (NOBYPASSRLS, owns nothing), with wallet RLS on.

Probe Result
Read with no tenant set fails: "unrecognized configuration parameter"
Read inside a tenant transaction only that tenant's rows; other tenants 0
Update across tenants 0 rows
Insert across tenants refused by the policy
Callback class ids all 6 resolve
Inactivity dry run 0 failures
Full sweep, fake Google client 6 failures, all from the fake client, none from RLS
db:rls --expect wallet, db:drift, --check-baseline pass

There was no preview deploy: one with real Google credentials would write to real passes. The rehearsal runs the real store and sweep instead.

Verification (Node 22)

  • RED first: check-rls failed because RLS_BATCHES.wallet did not exist.
  • scripts/check-rls.test.mjs + scripts/check-migration-drift.test.mjs: 126/126.
  • packages/db: 319/320. The one failure is environmental: secret-material asserts that the repo root path ends in vyloop, and this worktree is named rls-unit6.

Risk: item 1 (an irreversible-in-effect change to which rows production queries see), item 2 (tenant isolation), item 5 (the production credential changes).

🤖 Generated with Claude Code

@juancodedev
juancodedev merged commit b74b0a6 into main Nov 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant